//
// Created by LENOVO on 2024/8/9.
//
#include "function.h"
void InitQueue(LinkQueue &Q)
{
    Q.front=Q.rear=(LinkNode*) malloc(sizeof(LinkNode));
    Q.front->next=NULL;
}
bool IsEmpty(LinkQueue Q)
{
    if(Q.front==Q.rear)
        return true;
    else
        return false;
}
void InQueue(LinkQueue &Q,Element m)
{
    LinkNode  *s=(LinkNode*) malloc(sizeof (LinkNode));
    s->data=m;s->next=NULL;
    Q.rear->next=s;
    Q.rear=s;
}
bool DeQueue(LinkQueue &Q,Element &m)
{
    if(Q.front==Q.rear)
    {
        return false;
    }
    LinkNode  *p=Q.front->next;
    Q.front->next=p->next;
    m=p->data;
    if(p==Q.rear)
    {
        Q.front=Q.rear;
    }
    free(p);
    return true;
}